import rclpy
from rclpy.node import Node
from std_msgs.msg import String
class NodeSubscribe(Node):
    def __init__(self,name):
        super().__init__(name)
        self.get_logger().info("This is a subscriber:{}".format(name))
        self.command_subscribe = self.create_subscription(String,"command",self.command_callback,10)
    def command_callback(self, msg):
        speed = 0.0
        if msg.data == 'backup':
            speed = -0.2
        self.get_logger().info(f'receive [{msg.data}] order,speed:{speed}')

def main(args=None):
    rclpy.init(args=args)
    node = NodeSubscribe("topic_suber") 
    rclpy.spin(node) 
    rclpy.shutdown() 
